package org.balthie.demo.jdk.io.file.audio;

import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;

public class FileInputAudioDemo
{
    public static void main(String[] args)
    {
        File file = new File("D:\\Program\\BaiduNetdisk\\sounds\\1.wav");
        try (AudioInputStream stream = AudioSystem.getAudioInputStream(file))
        {
            Clip clip = AudioSystem.getClip();
            clip.open(stream);
            clip.start();
// 睡眠一会让 clip 播放音频文件。
            Thread.sleep(500);
        }
        catch (Exception ex)
        {
            System.out.println(ex.getMessage());
        }
    }
}